package com.admin.business.background.venusOaAttendancePunishSet;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 考勤处罚设置表
 * @create: 2023-10-31 16:39:41
 **/
@Service("venusOaAttendancePunishSetService")
@Slf4j
public class VenusOaAttendancePunishSetService{

    @Resource
    VenusOaAttendancePunishSetDao venusOaAttendancePunishSetDao;

    /**
     * 添加考勤处罚设置表,获取id数据
     *
     * @param cdoRequest - id:主键
     *                   - org_id:公司id
     *                   - project_id:项目id
     *                   - user_id:添加用户id
     *                   - holidays_times:节假日上班几倍工资
     *                   - missing_cards_money:缺卡罚当班工资几倍
     *                   - late_time1:迟到几分钟内
     *                   - late_time1_money:迟到几分钟内扣除金额
     *                   - late_time2:迟到几分钟以上
     *                   - late_time2_money:迟到几分钟以上扣除金额
     *                   - late_time3:超过几分钟扣除当班工资
     *                   - late_time4:迟到几分钟内不扣钱
     *                   - early_time1:早退几分钟内
     *                   - early_time1_money:早退几分钟内扣除金额
     *                   - early_time2:早退几分钟以上
     *                   - early_time2_money:早退几分钟以上扣除金额
     *                   - early_time3:早退几分钟扣除当班工资
     *                   - absenteeism_del_money:旷工每次扣工资
     *                   - early_time4:早退几分钟内不扣钱
     *                   - attendance_award_late:迟到是否扣除全勤奖 0:是1.否	
     *                   - attendance_award_leave:请假是否扣除全勤奖 0:是1.否	
     *                   - attendance_award_missing_cards:缺卡是否扣除全勤奖 0:是1.否	
     *                   - attendance_award_absenteeism:旷工是否扣除全勤奖 0:是1.否	
     *                   - storage_leave:非固定排班存储休息时间
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author Ht
     * @create: 2023-10-31 16:39:41
     */
    @OpenApi
    public Return addVenusOaAttendancePunishSet(CDO cdoRequest) {
        venusOaAttendancePunishSetDao.addVenusOaAttendancePunishSet(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新考勤处罚设置表数据
     *
     * @param cdoRequest - id:主键
     *                   - org_id:公司id
     *                   - project_id:项目id
     *                   - user_id:添加用户id
     *                   - holidays_times:节假日上班几倍工资
     *                   - missing_cards_money:缺卡罚当班工资几倍
     *                   - late_time1:迟到几分钟内
     *                   - late_time1_money:迟到几分钟内扣除金额
     *                   - late_time2:迟到几分钟以上
     *                   - late_time2_money:迟到几分钟以上扣除金额
     *                   - late_time3:超过几分钟扣除当班工资
     *                   - late_time4:迟到几分钟内不扣钱
     *                   - early_time1:早退几分钟内
     *                   - early_time1_money:早退几分钟内扣除金额
     *                   - early_time2:早退几分钟以上
     *                   - early_time2_money:早退几分钟以上扣除金额
     *                   - early_time3:早退几分钟扣除当班工资
     *                   - absenteeism_del_money:旷工每次扣工资
     *                   - early_time4:早退几分钟内不扣钱
     *                   - attendance_award_late:迟到是否扣除全勤奖 0:是1.否	
     *                   - attendance_award_leave:请假是否扣除全勤奖 0:是1.否	
     *                   - attendance_award_missing_cards:缺卡是否扣除全勤奖 0:是1.否	
     *                   - attendance_award_absenteeism:旷工是否扣除全勤奖 0:是1.否	
     *                   - storage_leave:非固定排班存储休息时间
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author Ht
     * @create: 2023-10-31 16:39:41
     */
    @OpenApi
    public Return updateVenusOaAttendancePunishSetById(CDO cdoRequest) {
        venusOaAttendancePunishSetDao.updateVenusOaAttendancePunishSetById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除考勤处罚设置表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author Ht
     * @create: 2023-10-31 16:39:41
     */
    @OpenApi
    public Return deleteVenusOaAttendancePunishSetById(CDO cdoRequest){
        int count = venusOaAttendancePunishSetDao.deleteVenusOaAttendancePunishSetById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除考勤处罚设置表数据
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-10-31 16:39:41
     */
    @OpenApi
    public Return deleteVenusOaAttendancePunishSet(CDO cdoRequest) {
        int count = venusOaAttendancePunishSetDao.deleteVenusOaAttendancePunishSet(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取考勤处罚设置表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author Ht
     * @create: 2023-10-31 16:39:41
     */
    @OpenApi
    public Return getVenusOaAttendancePunishSetById(CDO cdoRequest) {
        CDO cdoMapperResult = venusOaAttendancePunishSetDao.getVenusOaAttendancePunishSetById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取考勤处罚设置表数据列表
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-10-31 16:39:41
     */
    @OpenApi
    public Return getVenusOaAttendancePunishSetListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaAttendancePunishSetDao.getVenusOaAttendancePunishSetListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOaAttendancePunishSetDao.getVenusOaAttendancePunishSetCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取考勤处罚设置表数据列表
     *
     * @param cdoRequest - id:主键
     * @return
     * @author Ht
     * @create: 2023-10-31 16:39:41
     */
    @OpenApi
    public Return getVenusOaAttendancePunishSetListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaAttendancePunishSetDao.getVenusOaAttendancePunishSetListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOaAttendancePunishSetDao.getVenusOaAttendancePunishSetCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
